# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=genimage
pkgver=16
pkgrel=0
pkgdesc="tool to generate multiple filesystem and flash images from a tree"
url="https://github.com/pengutronix/genimage"
arch="all"
license="GPL-2.0-only"
makedepends="autoconf automake confuse-dev linux-headers"
checkdepends="
	bash
	cdrkit
	coreutils
	cramfs
	dosfstools
	dtc
	findutils
	genext2fs
	mtd-utils-ubi
	mtools
	qemu-img
	squashfs-tools
	util-linux-misc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/pengutronix/genimage/archive/refs/tags/v$pkgver.tar.gz"

case "$CARCH" in
	ppc64le) checkdepends="$checkdepends mtd-utils-jffs sfdisk" ;;
	s390x) : ;;
	*) checkdepends="$checkdepends android-tools mtd-utils-jffs sfdisk u-boot-tools" ;;
esac

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc
	make
}

check() {
	# ext2/3/4 tests fail with incorrect output
	# android-tools and u-boot-tools missing on ppc64le and s390x
	# first hdimage test and jfs test fails on s390x
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
7cb079d6ae889a744e2a3596b0eac737f7fdf1734c2024c71bb5ff85b93bff1d8ec26d61ee5b210aad4f0f9137968a6e256492c8c8376bafe2c5da2d12985a73  genimage-16.tar.gz
"
